import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[] num=new int[10000];
        int i=0;
        while(sc.hasNextInt()){
            num[i]=sc.nextInt();
            i++;
        }
        Arrays.sort(num);
        int s=0;
        int e=0;
        for(i=0;i<num.length-1;i++){
            if(num[i]!=0){
                if(num[i]+1!=num[i+1]&&num[i]!=num[i+1]){
                    s=num[i]+1;
                }
                if(num[i]==num[i+1]){
                    e=num[i];
                }
            }
        }
        System.out.println(s);
        System.out.println(e);
    }
}